/**
 * 商详页相关的接口
 */
import type {ProductDetailType, ProductSpecType, ReviewItemType, ReviewStatType} from "@/types/product";
import {request} from "@/utils/http";

/**
 * 获取商品详细数据
 * @param skuId
 */
export const getProductDetailData = (skuId: number) => {
    return request<ProductDetailType>({
        url: "/product/detail?id=" + skuId,
        method: "GET"
    })
}
/**
 * 获取商品对应的所有sku规格信息
 * @param skuId
 */
export const getProductInfoData = (skuId: number) => {
    return request<ProductSpecType>({
        url: "/product/spec?id=" + skuId,
        method: "GET"
    })
}
/**
 * 获取商品的评论的简要数据
 * @param skuId
 */
export const getReviewsSummaryData = (skuId: number) => {
    return request<ReviewStatType>({
        url: "/product-review/stat?id=" + skuId,
        method: "GET"
    })
}
export const getReviewsTopData = (skuId: number) => {
    return request<Array<ReviewItemType>>({
        url: "/product-review/top?id=" + skuId,
        method: "GET"
    })
}
/**
 * 判断是否已收藏当前商品
 * @param skuId
 */
export const isCollectedProduct = (skuId: number) => {
    return request<boolean>({
        url: "/collect-product/marked?id=" + skuId,
        method: "GET"
    })
}
/**
 * 收藏商品
 * @param skuId
 */
export const collectProduct = (skuId: number) => {
    return request<boolean>({
        url: "/collect-product/add?id=" + skuId,
        method: "GET"
    })
}
export const removeCollectProduct = (skuId: number) => {
    return request<boolean>({
        url: "/collect-product?id=" + skuId,
        method: "DELETE"
    })
}